package com.scott.ch040;

import redis.clients.jedis.Jedis;

import java.util.List;

/**
 * @author 黄后林
 * @version 1.0
 * @note
 * @date 2022-03-25 11:48:04
 *
 * 127.0.0.1:6379> del ages
 * (integer) 1
 */
public class RedisList {

    public static void main(String[] args) {

        Jedis jedis = new Jedis("192.168.88.129", 6379);

        //删除"ages"这个key 避免重复添加
        jedis.del("ages");

        // 往list中添加值
        // key="ages" value=[23,33,39,18]
        jedis.rpush("ages","23","33","39","18");

        //取值
        List<String> ages = jedis.lrange("ages", 0, -1);
        System.out.println(ages);

        System.out.println(jedis.lrange("ages", 1, 2));

    }
}
